package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.QuestionRecord;

@Mapper
public interface QuestionRecordDao {

    @Select("select * from m_question_record t where t.id = #{id}")
    QuestionRecord getById(Long id);

    @Delete("delete from m_question_record where id = #{id}")
    int delete(Long id);

    int update(QuestionRecord questionRecord);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into m_question_record(branch, check_status, create_time, detail, oversee_form, oversee_question_id, question_status, update_time, update_user) values(#{branch}, #{checkStatus}, #{createTime}, #{detail}, #{overseeForm}, #{overseeQuestionId}, #{questionStatus}, #{updateTime}, #{updateUser})")
    int save(QuestionRecord questionRecord);
    
    int count(@Param("params") Map<String, Object> params);

    List<QuestionRecord> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
    @Select("select * from m_question_record WHERE oversee_question_id = #{id} ORDER BY create_time DESC LIMIT 1")
    QuestionRecord queryRecord(Integer id);
}
